package com.whh.starter.autoConfig;

import com.whh.starter.cipher.CipherService;
import com.whh.starter.cipher.SmServiceImpl;
import com.whh.starter.properties.CipherProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(CipherProperties.class)
@ComponentScan(value = {"com.whh.starter.cipher"})
public class CipherAutoConfig {


//    @Bean
//    public CipherService cipherService(){
//        if (cipherProperties.isSm()) {
//            return new SmServiceImpl(cipherProperties);
//        }
//        return new CipherServiceImpl(cipherProperties);
//    }
    @Bean
    @ConditionalOnProperty(prefix = "whh.cipher",name = "sm",havingValue = "true")
    public CipherService cipherService(CipherProperties cipherProperties){
        return new SmServiceImpl(cipherProperties);
    }


}
